﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Niknak.Services.ServiceCore.TaskScheduler
{
    /// <summary>
    /// Contains data about the task iteration useful when handling events
    /// </summary>
    public class IterationEventArgs : EventArgs
    {
        /// <summary>
        /// Copy of the config settings object passed into the task processor for this iteration
        /// </summary>
        public object ConfigSettings { get; set; }
        /// <summary>
        /// The DateTime that the iteration was started on which this event was raised
        /// </summary>
        public DateTime IterationDate { get; set; }

        /// <summary>
        /// Allows for a fairly generic override flag when raising events after they would normally have been raised
        /// </summary>
        /// <remarks>Yeah, I know what you're thinking. But trust me - I did it this way for a reason.</remarks>
        private bool OverrideFlag = false;

        /// <summary>
        /// Constructs a new instance of the IterationEventArgs class, specifying the necessary property values
        /// </summary>
        /// <param name="configSettings">Copy of the config settings object passed into the task processor for this iteration</param>
        /// <param name="iterationDate">The DateTime that the iteration was started on which this event was raised</param>
        public IterationEventArgs(object configSettings, DateTime iterationDate)
        {
            ConfigSettings = configSettings;
            IterationDate = iterationDate;
        }

        /// <summary>
        /// Sets the OverrideFlag private property to true
        /// </summary>
        public void EnableOverrideFlag()
        {
            OverrideFlag = true;
        }

        /// <summary>
        /// Sets the OverrideFlag private property to false
        /// </summary>
        public void DisableOverrideFlag()
        {
            OverrideFlag = false;
        }

        /// <summary>
        /// Gets the value of the OverrideFlag private property
        /// </summary>
        /// <returns></returns>
        public bool GetOverrideFlag()
        {
            return OverrideFlag;
        }
    }
}
